# 示例 9: 自定义协程上下文管理器
import asyncio


class MyContextManager:
    async def __aenter__(self):
        print("Entering context")
        return self

    async def __aexit__(self, exc_type, exc_val, exc_tb):
        print("Exiting context")


async def main():
    async with MyContextManager() as cm:
        print("Inside context manager")
        await asyncio.sleep(1)


asyncio.run(main())
